package com.nageoffer.shortlink.admin.controller;

import com.nageoffer.shortlink.admin.common.convention.result.Result;
import com.nageoffer.shortlink.admin.common.convention.result.Results;
import com.nageoffer.shortlink.admin.remote.dto.ShortLinkRemoteService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: UrlTitleController
 * Package: com.nageoffer.shortlink.project.controller
 * Description:
 *
 * @Author Jetson
 * @Create 2024/10/22 19:52
 * @Version 1.0
 */
@RestController
@RequiredArgsConstructor
public class UrlTitleController {
    /**
     * 搞成单例模式，不要太挫了
     * 后序重构为Spring Cloud但是我不搞了
     */
    private ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService(){
        //盲猜是因为匿名实现了，看上去是 new 了接口，但是实际上并不是
    };
    @GetMapping("/api/short-link/admin/v1/title")
    public Result<String> getTitleByUrl(@RequestParam("url") String url){
        return shortLinkRemoteService.getTitleByUrl(url);
    }
}
